package top.lfyao.designpattern.details.mediator;

/**
 * 抽象中介者
 */
public abstract class Mediator {





    public abstract void send(String message, Colleague colleague);

}

class ConcreteMediator extends Mediator{
    // 需要了解所有的具体同事对象
    private ConcreteColleagueA concreteColleagueA;
    private ConcreteColleagueB concreteColleagueB;


    @Override
    public void send(String message, Colleague colleague) {
        if (concreteColleagueA==colleague)concreteColleagueB.receive(message);
        else concreteColleagueA.receive(message);
    }


    public ConcreteColleagueA getConcreteColleagueA() {
        return concreteColleagueA;
    }

    public void setConcreteColleagueA(ConcreteColleagueA concreteColleagueA) {
        this.concreteColleagueA = concreteColleagueA;
    }

    public ConcreteColleagueB getConcreteColleagueB() {
        return concreteColleagueB;
    }

    public void setConcreteColleagueB(ConcreteColleagueB concreteColleagueB) {
        this.concreteColleagueB = concreteColleagueB;
    }
}

